package com.wn55.hrms.mapper;

import com.wn55.hrms.entity.Role;
import com.wn55.hrms.service.vo.RoleVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author z
 */
@Repository
public interface RoleMapper {
    int deleteByPrimaryKey(Long id);

    int insert(Role record);

    Role selectByPrimaryKey(Long id);

    List<Role> selectAll();

    int updateByPrimaryKey(Role record);


    List<RoleVo> selectRoleByName(String name);
    //根据角色ID 查询出来他拥有的权限ID
    List<Long> selectPerIdByRoleId(Long id);

    @Update("update role set name= #{name} ,update_time=#{updateTime} where id = #{id}")
    void update(Role role);

    @Delete("delete from role_url_permission where role_id = #{id}")
    void deletePermissionByRoleId(Long id);

    void insertRolePermission(@Param("rid") Long id, @Param("pids") List<Long> pids);

    //根据管理员查询角色
    List<Role> selectRoleByManager(int id);

    @Delete("delete from employee_role where role_id = #{id}")
    void deleteManagerRoleByRoleId(int id);


    @Delete("delete from role_url_permission where role_id = #{id}")
    void deletePerRoleByRoleId(int id);
}